﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HZ.Supervise.Web.Master
{
    public partial class MasterPageIframeComparison : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindSort();
        }

        /// <summary>
        /// 绑定类型
        /// </summary>
        private void BindSort()
        {
            HZ.Supervise.IBLL.IBLL_ProcureCatalog pre = HZ.Supervise.BLLFactory.IBLL_ProcureCatalog();
            int outcount;
            DataTable dt = pre.GetSort("",1,0,out outcount);
            droSort.DataSource = dt;
            droSort.DataTextField = "SortName";
            droSort.DataValueField = "SortID";
            droSort.DataBind();
        }

        /// <summary>
        /// 点击对比
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtTimeFrom.Text))
            {
                this.Page.RegisterStartupScript("", "<script>alert('请选择对比起始时间')</script>");
                return;
            }
            if (string.IsNullOrEmpty(this.txtTimeTo.Text))
            {
                this.Page.RegisterStartupScript("", "<script>alert('请选择对比结束时间')</script>");
                return;
            }
            string where="";
            string timefrom = this.txtTimeFrom.Text;
            string timeto = this.txtTimeTo.Text;
            string sid = "";
            switch (this.RadioButtonList1.SelectedValue.ToString())
            {
                case "1":
                     where = this.HidHosId.Value;
                     sid= this.droSort.SelectedValue.ToString();
                     if (string.IsNullOrEmpty(where))
                     {
                         this.Page.RegisterStartupScript("", "<script>alert('请选择对比医院')</script>");
                         return;
                     }
                     else if (where.Split(',').Length < 3)
                     {
                         this.Page.RegisterStartupScript("", "<script>alert('请选择最少两家医院进行对比')</script>");
                         return;
                     }
                     else
                     {
                         this.Page.RegisterStartupScript("", "<script>seturl1('" + where + "','" + timefrom + "','" + timeto + "','" + sid + "');</script>");
                     }
                    break;
                case "2":
                     sid = this.droSort.SelectedValue.ToString();
                     where = this.HidAreaId.Value;
                     if (string.IsNullOrEmpty(where))
                     {
                         this.Page.RegisterStartupScript("", "<script>alert('请选择对比地区')</script>");
                         return;
                     }
                     else if (where.Split(',').Length < 3)
                     {
                         this.Page.RegisterStartupScript("", "<script>alert('请选择最少两个区域进行对比')</script>");
                         return;
                     }
                     else
                     {
this.Page.RegisterStartupScript("", "<script>seturl2('" + where + "','" + timefrom + "','" + timeto + "','" + sid + "');</script>");
                     }
                     
                    break;
                default:
                    sid = this.HidSortId.Value;
                    this.Page.RegisterStartupScript("", "<script>seturl3('" + timefrom + "','" + timeto + "','" + sid + "');</script>");
                    break;
            }
        }



    }
}
